/*
 * Copyright © 2004-2014 chenYuan. All rights reserved.
 * @Website:wwww.jspx.net
 * @Mail:39793751@qq.com
 * @author: chenYuan , 陈原
 * @License: Jspx.net Framework Code is open source (LGPL)，Jspx.net Framework 使用LGPL 开源授权协议发布。
 * @jvm:jdk1.6+  x86/amd64
 *
 */
package com.jspx.sober;

import com.jspx.sober.util.DataMap;
import com.jspx.json.JSONException;
import java.io.Serializable;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Map;
import java.util.List;
import java.sql.ResultSet;


/**
 * Created by IntelliJ IDEA.
 * User:chenYuan (mail:39793751@qq.com)
 * Date: 2007-1-9
 * Time: 23:20:44
 */
public interface SoberSupport extends Serializable
{

    void setSoberFactory(SoberFactory soberFactory);

    SoberFactory getSoberFactory();

    TableModels getSoberTable(Class cla);

    String getColumnModels(Class cla,String[] notFiled, String[] editColumns, String[] hideColumns) throws JSONException;

    int getMaxRows();

    Transaction createTransaction() throws SQLException;

    Object get(Class aClass, Serializable serializable) throws SQLException;

    Object get(Class aClass, Serializable serializable, boolean loadChild) throws SQLException;

    Object get(Class aClass, Serializable field, Serializable serializable, boolean loadChild) throws SQLException;

    Object load(Class aClass, Serializable serializable) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException;

    Object load(Class aClass, Serializable serializable, boolean loadChild) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException;

    Object load(Class aClass, Serializable field, Serializable serializable, boolean loadChild) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException;    

    int save(Object object) throws Exception;

    int save(Object object, boolean child) throws Exception;

    int save(Collection collection) throws Exception;

    int batchSave(Collection collection) throws Exception;

    int delete(Object o) throws Exception;

    int delete(Class aClass, Serializable serializable);

    int delete(Class aClass, String field, Serializable serializable);

    int delete(Object o, boolean delChild) throws Exception;

    int delete(Class aClass, Object[] ids, boolean delChild);

    int delete(Class aClass, Serializable serializable, boolean delChild) throws Exception;

    int delete(Class aClass, String field, Serializable serializable, String term, boolean delChild) throws Exception;

    int deleteNexus(Object o) throws Exception;

    boolean deleteAll(Collection collection) throws Exception;

    Object getUniqueResult(String sql, Map<String, Object> valueMap) throws Exception;

    int update(Collection collection) throws Exception;

    int update(Object object) throws Exception;

    int update(Object object, String[] updateFiled);

    int update(String sqlText);

    int update(String sqlText, Object[] params);

    int update(Class cla,String sqlText, Object params) throws IOException;

    boolean execute(String sqlText);

    boolean execute(String sqlText, Object[] params);

    boolean execute(Class cla,String sqlText, Object params) throws IOException;

    int saveOrUpdate(Object object) throws Exception;

    void loadNexusList(TableModels soberTable, List list) throws Exception;

    void loadNexusList(Class cla, List list) throws Exception;

    Object loadColumnsValue(Class cla, ResultSet resultSet) throws Exception;

    Object loadColumnsValue(TableModels soberTable, ResultSet resultSet) throws Exception;

    void loadNexusValue(TableModels soberTable, Object result) throws Exception;

    List<DataMap<String, Object>> queryForList(String sql, Object[] parm, int currentPage, int totalCount);

    List queryForList(Class cla, String sql, Object[] parm, int currentPage, int totalCount, boolean loadChild);

    Object getUniqueResult(String sql) throws Exception;

    Object getUniqueResult(String sql, Object[] params) throws Exception;

    Object getUniqueResult(String sql, Object o) throws Exception;

    Object getUniqueResult(Class cla,String sql,Object o) throws Exception;

    void calcUnique(TableModels soberTable,Object obj) throws Exception;
    
    Criteria createCriteria(Class cla);

    SqlMapClient buildSqlMap();

    String getCreateTableSQL(Class createClass) throws Exception;

    boolean tableExists(Class cla) throws Exception;

    boolean dropTable(Class cla) throws Exception;

    List<DataMap> prepareQuery(String sqlText, Object parm[]);

    int prepareUpdate(String sqlText, Object parm[]);

    boolean prepareExecute(String sqlText, Object parm[]);

    List getExpressionList(Class aClass, String term, String orderBy, int currentPage, int totalCount,boolean loadChild) throws Exception;

    int getExpressionCount(Class aClass, String term) throws Exception;

    //--------------------
    long getTableMaxId(Class cla);

    String[] getTableNames();

    long getDataBaseSize(String databaseName);

    boolean alterSequenceStart(Class cla,long startId);

    String getSequenceName(Class cla);

    void validator(Object obj) throws Exception;

    boolean containsField(Class cla,String field);
    
    void debugPrint(String info);

    int getTid();

    void setTid(int tid);

    //清除缓存
    void evict(Class cla);

    void evictList(Class cla);

    void evictLoad(Class cla);

}